package com.augurit.gzcgwsp.ywcmn.convert;

import java.util.ArrayList;
import java.util.List;
import org.dozer.DozerBeanMapper;
import com.augurit.gzcgwsp.ywcmn.entity.YwComQyxx;
import com.augurit.gzcgwsp.ywcmn.web.form.YwComQyxxForm;

public class YwComQyxxConvertor {
	public static YwComQyxxForm convertVoToForm(YwComQyxx entity) {
		if (entity == null) return null;
		
		return new DozerBeanMapper().map(entity, YwComQyxxForm.class);
	}
	
	public static void convertFormToVo(YwComQyxxForm form, YwComQyxx entity) {
		if (form == null) return;
        if (entity == null) entity = new YwComQyxx();
        
        new DozerBeanMapper().map(form, entity);
	}
	
	public static List<YwComQyxxForm> convertVoListToFormList(List<YwComQyxx> ywComQyxxList) {
		if(ywComQyxxList != null && ywComQyxxList.size() > 0) {
			List<YwComQyxxForm> ywComQyxxFormList = new ArrayList<YwComQyxxForm>();
			for(int i=0; i<ywComQyxxList.size(); i++) {
				ywComQyxxFormList.add(convertVoToForm(ywComQyxxList.get(i)));
			}
			return ywComQyxxFormList;
		}
		return null;
	}
	
	public static List<YwComQyxx> convertFormListToVoList(List<YwComQyxxForm> ywComQyxxFormList) {
		if(ywComQyxxFormList != null && ywComQyxxFormList.size() > 0) {
			List<YwComQyxx> ywComQyxxList = new ArrayList<YwComQyxx>();
			for(int i=0; i<ywComQyxxFormList.size(); i++) {
				YwComQyxx ywComQyxx = new YwComQyxx();
				convertFormToVo(ywComQyxxFormList.get(i), ywComQyxx);
				ywComQyxxList.add(ywComQyxx);
			}
			return ywComQyxxList;
		}
		return null;
	}
}